<?php

    class x_remots {
        protected $db_man;
        protected $select = "select id_remot, clau, ip from x_remots";
        protected $delete = "delete from x_remots where clau='%s' and ip='%s'";
        protected $insert = "insert into x_remots(clau, ip) values ('%s', '%s')";
        
        function x_remots($dbm) {
            $this->db_man = $dbm;
        }
        
        function add_remot($clau, $ip) {
        	return ($this->db_man->do_dml(sprintf($this->insert, $clau, $ip)));
        }
        
        function delete_remot($clau, $ip) {
            return ($this->db_man->do_dml(sprintf($this->delete, $clau, $ip)));
        }
        
        function get_remots() {
            $csr = $this->db_man->do_query($this->select);
            return ($csr);
        }
        
        function is_valid_ip($ip) {
        	return (long2ip(ip2long($ip)) == $ip);
        }
    }

?>